package com.servertrack

import grails.test.mixin.TestFor
import spock.lang.Specification

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Request)
class RequestSpec extends Specification {

/*	Request request
    def setup() {
		mockForConstraintsTests(Hotel)
		request = new Request(title:"Request",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
    }

   void testConstraintsTitleBlank() {
		request = new Request(title:"",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
		assertFalse request.validate()
		assertEquals 'blank', request.errors['title']

		request = new Request(title:"Request",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
		assertTrue request.validate()
    }
   
   void testConstraintsTitleSize() {
	   request = new Request(title:"q",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'size', request.errors['title']

	   request = new Request(title:"jdsfbvairebviunfiduvniauerhnvuiondkjvnzkdjfnvkajsdnfvkjnhreounvdnfverjvojiojzlsdkmv;ALSDmkvd",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'size', request.errors['title']

	   request = new Request(title:"Request",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertTrue request.validate()
   }

       void testConstraintsCompanyNameBlank() {
		request = new Request(title:"Request",company_name:"",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
		assertFalse request.validate()
		assertEquals 'blank', request.errors['company_name']

		request = new Request(title:"Request",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
		assertTrue request.validate()
    }
   
   void testConstraintsCompanyNameSize() {
	   request = new Request(title:"q",company_name:"r",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'size', request.errors['company_name']

	   request = new Request(title:"Request",company_name:"lkdsjfkasfaoewraiujhfohds;afa'soijlaskdfjngjaerhoiaegjdfkgjdfgirejgidfjg9r5u85u",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'size', request.errors['company_name']

	   request = new Request(title:"Request",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertTrue request.validate()
   }
   
   
   void testConstraintsCountPersonsBlank() {
	   request = new Request(title:"Request",company_name:"turist",count_persons:"",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'blank', request.errors['count_persons']

	   request = new Request(title:"Request",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertTrue request.validate()
   }
   
   void testConstraintsNameTouristSize() {
	   request = new Request(title:"title Tur",company_name:"company name",count_persons:"2",name_tourist:"e",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'size', request.errors['name_tourist']

	   request = new Request(title:"Request",company_name:"company name 5",count_persons:"2",name_tourist:"ldfmbvdkfmbksdfmblksmtgisrmtbrsgoftidfklmba'seprkogpeor",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'size', request.errors['name_tourist']

	   request = new Request(title:"Request",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertTrue request.validate()
   }
      
   void testConstraintsNameTouristBlank() {
	   request = new Request(title:"Request",company_name:"turist",count_persons:"",name_tourist:"",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'blank', request.errors['name_tourist']

	   request = new Request(title:"Request",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertTrue request.validate()
   }
   
   void testConstraintsPhoneSize() {
	   request = new Request(title:"title Tur",company_name:"company name",count_persons:"2",name_tourist:"e",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'size', request.errors['phone_number']

	   request = new Request(title:"Request",company_name:"company name 5",count_persons:"2",name_tourist:"ldfmbvdkfmbksdfmblksmtgisrmtbrsgoftidfklmba'seprkogpeor",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'size', request.errors['phone_number']

	   request = new Request(title:"Request",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertTrue request.validate()
   }   
   
   void testConstraintsPhoneBlank() {
	   request = new Request(title:"Request",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha ",phone_number:"",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'blank', request.errors['phone_number']

	   request = new Request(title:"Request",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertTrue request.validate()
   }
   
   void testConstraintsDescriptionSize() {
	   request = new Request(title:"title Tur",company_name:"company name",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"q",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'size', request.errors['description']

	   request = new Request(title:"Request",company_name:"company name 5",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"jsfbvseryhbvaiueyrvhbaeryivbhdifshbveruhg598ghdfighsdjkfghskjlhkdjhgal;eksrjghareijkghkjdfs",birthDate: new Date("1989/1/9"))
	   assertFalse request.validate()
	   assertEquals 'size', request.errors['description']

	   request = new Request(title:"Request",company_name:"turist",count_persons:"2",name_tourist:"Petrova Masha",phone_number:"4756512",description:"qweqwdsdcvdsvadfv",birthDate: new Date("1989/1/9"))
	   assertTrue request.validate()
   }
   
   void testConstraintsDescriptionNullable() {
	   request.description = ''
	   assertTrue request.validate()
	   assertNull request.errors['description']
   }
   
   void testConstraintsBirthDateNullable() {
		request.birthDate = null
		assertTrue request.validate()
		assertNull request.errors['birthDate']
	}*/
   
}
